<template>
	<view class="content-header-f">
		<view v-if="status==1" class="flex-column flex-item-center">
			<image class="success-img" src="../../static/order/cg.png" mode="scaleToFill"></image>
			<view class="text1">支付成功</view>
		</view>
		<view v-if="status==2" class="flex-column flex-item-center">
			<image class="success-img" src="../../static/order/sb.png" mode="scaleToFill"></image>
			<view class="text1">支付失败</view>
		</view>
		<view v-if="status==0" class="flex-column flex-item-center">
			<image class="success-img" src="../../static/order/ss.png" mode="scaleToFill"></image>
			<view class="text1">查询中...</view>
		</view>
		<view v-if="status!=0" class="flex-column flex-item-center">
			<view class="btn" @tap="chakan">查看订单</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				status:2,
				order_num:"",
				num:0,
				// orderInfo:null,
			}
		},
		onLoad(opt) {
			if(opt.status){
				this.status = opt.status;
			}
			if(opt.order_num){
				this.order_num = opt.order_num;
			}
			// console.log(this.status);
			if(this.status==0){
				this.getPayDetail();
			}
			this.$store.dispatch("getOrderStatus")
		},
		methods:{
			//查看订单
			chakan(){
				uni.redirectTo({
					url:'/pages/order/order_list?back=0'
				})
			},
			//获取支付订单详情
			getPayDetail(){
				let num = this.num;
				if(num>3){
					this.status = 2
					return
				}
				let that = this;
				this.$api.getOrderPay({
					order_num:this.order_num
				}).then(res=>{
					that.num++;
					if(res.status==1){
						that.status = 1;
					}else if(res.status==0){
						setTimeout(()=>{
							that.getPayDetail();
						},1000)
					}
				})
				
			}
		}
	}
</script>

<style lang="scss">
	.btn{
		width: 400rpx;
		height: 90rpx;
		background: linear-gradient(90deg, $default-button-color 0%, $default-button-end-color 100%);
		border-radius: 45rpx 45rpx 45rpx 45rpx;
		opacity: 1;
		font-size: 30rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: $default-button-foncolor;
		text-align: center;
		line-height: 90rpx;
		// margin-left: 175rpx;
		margin-top: 126rpx;
	}
	.text1{
		font-size: 30rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		text-align: center;
		margin-top: 26rpx;
	}
	.success-img{
		width: 337rpx;
		height: 228rpx;
		margin-top: 294rpx;
	}
</style>